<extend name="template/base_index" />


<block name="area_header">
	<link type="text/css" rel="stylesheet" href="__CDN__/select2/4.0.0/css/select2.min.css" />
	<script type="text/javascript" src="__CDN__/select2/4.0.0/js/select2.full.js"></script>
	<script type="text/javascript" src="__CDN__/select2/4.0.0/js/i18n/zh-CN.js"></script>
	<style type="text/css">
		.checkbox{
			margin: 0px;
		}
		.panel-default{
			margin-bottom: 10px;
		}
	</style>
</block>

<block name="area_body">
	{:W('Menus/topbar')}
	<div class="admin-main container-fluid">
		{:W('Menus/left')}
		<div class="admin-main-content">
			{:W('Menus/breadcrumb')}
			<div class="table-responsive well ">

				<!-- Nav tabs -->
				<ul class="nav nav-tabs" role="tablist">
					<li role="presentation"><a href="{:U('Ucenter/AuthManage/user')}" role="tab">成员授权</a>
					</li>
					<li role="presentation"><a href="{:U('Ucenter/AuthManage/access')}" role="tab">访问授权</a>
					</li>
					<li role="presentation"  class="active">
					 <a href="{:U('Ucenter/AuthManage/apiaccess')}" >API授权</a>
					</li>
				</ul>

				<!-- Tab panes -->
				<div class="tab-content">
					<div role="tabpanel" class="tab-pane " id="user">
						loading...
					</div>

					<div role="tabpanel" class="clearfix tab-pane active" id="access">
						<div class="clearfix">
							<!-- 过滤\查询按钮 -->
							<div class="filter-controls pull-right">
								<form action="__SELF__" class="form-inline groupForm" method="post">
									<div class="form-group-sm">
										<label class="control-label">用户组</label>
										<select id="groups" name="groupid" class="form-control">
											<volist name="groups" id="vo">
												<option <eq name="groupid" value="$vo.id">selected="selected"</eq> value="{$vo.id}" >{$vo.title}</option>
											</volist>
										</select>
									</div>
								</form>

							</div>

							<!-- 过滤\查询按钮 -->
							<div class="filter-controls pull-left clearfix">
								<form action="__SELF__" class="form-inline moduleForm" method="post">
									<div class="form-group-sm">
										<label class="control-label">所属模块</label>
										<select id="modules" name="modulename" class="form-control">
											<volist name="modules" id="vo">
												<option <eq name="modulename" value="$vo['module']">selected="selected"</eq> value="{$vo.module}" >{$vo.module}</option>
											</volist>
										</select>
									</div>
								</form>

							</div>
						</div>
						<form class="clearfix rulesForm form" method="post" enctype="application/x-www-form-urlencoded">
							<input type="hidden" name="groupid" value="{$groupid}" />
							<fieldset>
								<legend>API权限配置(暂未实现)
							</legend>
							<div class="form-group">
								<a target-form="rulesForm" href="{:U('Ucenter/AuthGroup/writeRules')}" class="ajax-post btn btn-sm btn-primary"><i class="fa fa-save"></i>{:L('BTN_SAVE')}</a>
								<a href="{:U('Ucenter/AuthGroup/index')}" class="btn btn-sm btn-default"><i class="fa fa-close"></i>{:L('BTN_CANCEL')}</a>
							</div>
							
							<volist name="authrules" id="vo">
								<div class="checkbox">
														<label>
															<input type="checkbox" name="rules[]" value="{$vo.id}" id="rules{$vo.id}" {:strpos($rules,$vo['id'].',') === false?"":"checked='checked'"} />{$vo.title}
														</label>
									</div>
							</volist>
							<!--<volist name="accessTree" id="vo">
								
								<div class="panel panel-default">
									<div class="panel-heading">
										<div class="checkbox">
														<label>
															<input type="checkbox" name="menulist[]" value="{$vo.id}" id="rules{$vo.id}" onclick="selectSubs('{$vo.id}');" {:strpos($rules,$vo['id'].',') === false?"":"checked='checked'"}/>{$vo.title}
														</label>
													</div>
										</div>
									<if condition="count($vo['_child']) gt 0">
										<div class="panel-body">
											<volist name="vo._child" id="child">
												<div class="pull-left small">
													<div class="checkbox">
														<label>
															<input class="parent{$vo.id}" type="checkbox" name="menulist[]" value="{$child.id}" {:strpos($rules,$vo['id'].',') === false?"":"checked='checked'"} />{$child.title}
														</label>
													</div>
												</div>
											</volist>
										</div>
									</if>

								</div>

							</volist>-->
							
							<div class="form-group">
								<a target-form="rulesForm" href="{:U('Ucenter/AuthGroup/writeRules')}" class="ajax-post btn btn-sm btn-primary"><i class="fa fa-save"></i>{:L('BTN_SAVE')}</a>
								<a href="{:U('Ucenter/AuthGroup/index')}" class="btn btn-sm btn-default"><i class="fa fa-close"></i>{:L('BTN_CANCEL')}</a>
							</div>
							</fieldset>
						</form>
					</div>
				</div>

			</div>
		</div>
		<!-- END admin-main-content -->
	</div>
	<!-- END admin-main-->
</block>

<block name="area_footer">
	
	<script type="text/javascript">
		function selectSubs(id) {
			if ($("#rules" + id).prop("checked")) {
				$(".parent" + id).prop("checked", "checked");
			} else {
				$(".parent" + id).prop("checked", "");
			}
		}

		$(function() {

			$("#groups").change(function() {
				$(".groupForm").submit();
			});
			
			
			$("#modules").change(function() {
				$(".moduleForm").submit();
			});

		})
	</script>
</block>